package entities;

import java.util.ArrayList;

/**
 * Entity Class for Games. Camp is a Event with a type, a result (goalsScored,
 * goals Succeded), a meeting time and place.
 * 
 * @author MK
 * @see entities.Event
 * 
 */
public class Game extends Event {

	private String type;
	private int goalsScored;
	private int goalsSucceeded;
	private Long meetingTime;
	private Address meetingPlace;

	private Game() {
		super();
	}

	public Game(Long date, Address place, ArrayList<Participant> participants,
			String type, int goalsScored, int goalsSucceeded, Long meetingTime,
			Address meetingPlace) {
		super(date, place, participants);
		this.type = type;
		this.goalsScored = goalsScored;
		this.goalsSucceeded = goalsSucceeded;
		this.meetingPlace = meetingPlace;
		this.meetingTime = meetingTime;
	}

	public Game(Game game) {
		this(game.date, game.place, game.participants, game.type,
				game.goalsScored, game.goalsSucceeded, game.meetingTime,
				game.meetingPlace);
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result + goalsScored;
		result = prime * result + goalsSucceeded;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		Game other = (Game) obj;
		if (goalsScored != other.goalsScored)
			return false;
		if (goalsSucceeded != other.goalsSucceeded)
			return false;
		if (type != other.type)
			return false;
		return true;
	}

	@Override
	public String toString() {
		return "Game [goalsScored=" + goalsScored + ", goalsSucceeded="
				+ goalsSucceeded + ", type=" + type + ", date=" + date
				+ ", participants=" + participants + ", place=" + place + "]";
	}

	public int compareTo(Game game) {

		if (super.compareTo((Event) game) != 0) {
			return super.compareTo((Event) game);
		} else {
			return this.type.compareTo(game.type);
		}

	}

	public String getType() {
		return type;
	}

	public int getGoalsScored() {
		return goalsScored;
	}

	public int getGoalsSucceeded() {
		return goalsSucceeded;
	}
}
